package com.cskaoyan.mall.product.controller;

import com.cskaoyan.mall.common.result.Result;
import com.cskaoyan.mall.product.dto.FirstLevelCategoryDTO;
import com.cskaoyan.mall.product.dto.SecondLevelCategoryDTO;
import com.cskaoyan.mall.product.dto.ThirdLevelCategoryDTO;
import com.cskaoyan.mall.product.service.CategoryService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
public class AdminCategoryController {
    @Autowired
    CategoryService categoryService;

    @GetMapping("/getCategory1")
    public Result<List<FirstLevelCategoryDTO>> getCategory1(){
        //获取一级列表，应该是获取一个什么表的
        List<FirstLevelCategoryDTO> firstLevelCategory = categoryService.getFirstLevelCategory();
        return Result.ok(firstLevelCategory);
    }

    @GetMapping("/getCategory2/{categoryId}")
    public Result<List<SecondLevelCategoryDTO>> getCategory2(@PathVariable Long categoryId){
        List<SecondLevelCategoryDTO> secondLevelCategory = categoryService.getSecondLevelCategory(categoryId);
        return Result.ok(secondLevelCategory);
    }
    @GetMapping("/getCategory3/{categoryId}")
    public Result<List<ThirdLevelCategoryDTO>> getCategory3(@PathVariable Long categoryId){
        List<ThirdLevelCategoryDTO> secondLevelCategory = categoryService.getThirdLevelCategory(categoryId);
        return Result.ok(secondLevelCategory);
    }




}
